<%@page import="edu.sjsu.itack.dao.BoardDao"%>
<%@page import="edu.sjsu.itack.entity.User"%>
<%@ page language="java" contentType="text/html; charset=US-ASCII"
	pageEncoding="US-ASCII"%>
<%@ page import="edu.sjsu.itack.entity.Board"%>
<%
	User user = (User) session.getAttribute("user");
    Board[] boardArr = new BoardDao().getAllBoardsForUser(user.getUserId());
%>
<%@include file="header.jsp"%>
<aside class="aside">
	<ul class="nav nav-pills nav-stacked" id="myTab">
		<li class="dropdown"><a class="dropdown-toggle"
			data-toggle="dropdown" href="#">Settings<b class="caret"></b></a>
			<ul class="dropdown-menu">
				<li><a href="#profile" data-toggle="tab">Edit Profile</a></li>
				<li><a href="inviteFriends.jsp">Invite Friends</a></li>
			</ul></li>
		<li class="active dropdown"><a class="dropdown-toggle"
			data-toggle="dropdown" href="#">Tacks<b class="caret"></b></a>
			<ul class="dropdown-menu">
				<li><a href="uploadWeb.jsp">Tack from Website</a></li>
				<li><a href="uploadTack.jsp">Upload tack</a></li>
			</ul></li>
		<li><a class="dropdown-toggle" href="board.jsp">Boards</a></li>
	</ul>
</aside>
<section class="section" id="section">
	<div class="upload-tack">
		<form class="form-signin" action="UploadTack.do" method="post" enctype="multipart/form-data">
			<fieldset>
				<legend>Upload Tack</legend>
				<input type="text" class="form-control" name="tackName"
					placeholder="Name your Tack" required autofocus>
					<input type="file" name="uploadImg">

				<select id="boardId" name="boardId" class="form-control">
				    <option value="0">Choose Board</option>
					<%
						if (boardArr != null && boardArr.length > 0) {
						int cnt = 0;
							for (Board bd : boardArr) {
								String boardName = bd.getName();
					%>
					<option value="<%=bd.getBoardId()%>"><%=bd.getName()%></option>
					<%
						}
						}
					%>
				</select>
				<textarea name="tackDesc" class="form-control" rows="4" cols="47"
					placeholder="Tack Description"></textarea>
				<button class="btn btn-lg btn-primary btn-block" type="submit">Upload</button>
			</fieldset>
		</form>
	</div>
</section>
